﻿using System;

namespace WpfFeeCalculator.Model
{
    public struct CalculationViewChanges
    {
        private const int ZOffset = 25;
        public int Row { get; set; }
        public int Column { get; set; }
        private int GuiColumn { get { return Column + 1; } }
        private int GuiRow { get { return Row + 1; } }
        // only until 'Z'
        public string Address
        {
            get
            {
                const int A = 65;
                return Column > ZOffset ? String.Concat("Column:", GuiColumn, ", Row:", GuiRow) : String.Concat(Convert.ToChar(A + Column), GuiRow);
            }
        }
        public string Message { get; set; }
        public decimal? InitialValue { get; set; }
        public decimal? NewValue { get; set; }
        public decimal? FiftyBpTolerance
        {
            get
            {
                if (!NewValue.HasValue || !InitialValue.HasValue || InitialValue.Value == 0) return null;
                return (NewValue.Value - InitialValue.Value) / InitialValue.Value;
            }
        }

        public bool Accepted { get; set; }
    }
}
